package pyf.demo10;

/**
 * @author pengyifeng
 * @version 5.1
 * @ClassName ThreadDaemon.java
 * @Description 守护线程
 * 线程分为 用户线程 和 守护线程
 * 一般创建默认为用户线程
 * @createTime 2021年07月27日 10:42:00
 */
public class ThreadDaemon {

    static class You implements Runnable {

        @Override
        public void run() {
            for (int i = 0; i < 36500; i++) {
                System.out.println("我是普通人已经生活了第" + i + "天");
            }
        }


    }

    static class God implements Runnable {
        @Override
        public void run() {
            while (true) {
                System.out.println("我是上帝与你同在");
            }
        }
    }

    public static void main(String[] args) {
        You you = new You();
        God god = new God();
        Thread thread = new Thread(you);
        Thread thread1 = new Thread(god);
        thread1.setDaemon(true);
        thread.start();
        thread1.start();
    }
}
